package com.hikeen.launcherx.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.hardware.usb.UsbManager;
import android.util.Log;


/**
 * @ClassName USB
 * @Description TODO
 * @Author wzz
 * @Date 2021/12/14 11:19
 * @Version 1.0
 */
public class USBBroadcastReceiver extends BroadcastReceiver {

    private static String TAG = "USBBroadcastReceiver";

    private static USBBroadcastReceiverListener usbBroadcastReceiverListener;


    public interface USBBroadcastReceiverListener {
        void onUSBBroadcastReceiver(boolean type);
    }

    public static void setUSBBroadcastReceiverListener(USBBroadcastReceiverListener listener) {
        usbBroadcastReceiverListener = listener;
    }


    @Override
    public void onReceive(Context context, Intent intent) {
        switch (intent.getAction()) {
            case UsbManager.ACTION_USB_DEVICE_ATTACHED:
                Log.d(TAG, "onReceive: ACTION_USB_DEVICE_ATTACHED");
                break;
            case UsbManager.ACTION_USB_DEVICE_DETACHED:
                Log.d(TAG, "onReceive: ACTION_USB_DEVICE_DETACHED");
                break;
            default:
                break;
        }
    }
}
